package com.liuhx.mapper;

import com.liuhx.entity.ModelsEntity;
import com.liuhx.mapper.sql.BrandSql;
import com.liuhx.mapper.sql.ModelsSql;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by liuhx on 2017/7/13.
 */
public interface ModelsMapper {
    @InsertProvider(type = ModelsSql.class,method = "insertModels")
    @Options(useGeneratedKeys = true, keyProperty = "modelsId")
    void insertModels(List<ModelsEntity> modelsEntityList);

    @Select("select modelsName,modelsUrl,brandId from models_info where brandId = #{brandId}")
    @Results(
            {
                    @Result(property = "modelsName",column = "modelsName"),
                    @Result(property = "modelsUrl",column = "modelsUrl"),
                    @Result(property = "brandId",column = "brandId")
            }
    )
    List<ModelsEntity> findAllModels(int brandId);
    @Select("select * from models_info where brandId = #{brandId}")
    List<ModelsEntity> findAllModelsHaveId(int brandId);
}
